Skip to content

Enable easy passing of environment variables in browser.script.iffe.js#649

Open
ledsun wants to merge 1 commit intoruby:mainfrom
ledsun:codex/browser-script-data-env
Open

Enable easy passing of environment variables in browser.script.iffe.js#649
ledsun wants to merge 1 commit intoruby:mainfrom
ledsun:codex/browser-script-data-env

Conversation

@ledsun
Copy link
Copy Markdown
Contributor

@ledsun ledsun commented May 5, 2026

This change is intended to meet the expectations of #645 (comment).

Summary

  • Add browser.script.iife.js support for passing Ruby VM environment variables via a data-env attribute
  • Add a browser Ruby::Box example that enables RUBY_BOX=1 through data-env
  • Cover data-env and the Ruby::Box example with Playwright tests, and document data-env in the cheat sheet

Notes

  • data-env:
    • It passes environment variables at VM startup, so supporting both WASI Preview 1 and WASI Preview 2 is appropriate.
    • There is no particular reason to exclude WASI Preview 2 from data-env support.
    • The integration test confirms that environment variables are also passed on WASI Preview 2.
  • Ruby::Box example:
    • It is a useful practical data-env example because Ruby::Box requires RUBY_BOX=1 at VM startup.
    • Ruby::Box's require hook copies extension libraries to /tmp before loading them.
    • This works with the WASI Preview 1 browser shim.
    • The WASI Preview 2 browser component setup does not currently initialize writable /tmp, so the Ruby::Box example does not work there yet.
  • CI behavior:
    • Ruby 3.x is skipped because Ruby::Box is not available there.
    • Ruby 4.0+ / head with WASI Preview 2 is also skipped because writable /tmp is not currently provided.
  • Future work:
    • To make Ruby::Box work on WASI Preview 2, the Preview 2 browser filesystem needs a writable preopen equivalent to /tmp.
    • That is outside the scope of this data-env PR.

@ledsun ledsun changed the title [codex] Add browser data-env support Enable easy passing of environment variables in browser.script.iffe.js May 5, 2026
@ledsun ledsun force-pushed the codex/browser-script-data-env branch 3 times, most recently from 31b13db to 750f4b4 Compare May 6, 2026 02:12
@ledsun ledsun force-pushed the codex/browser-script-data-env branch from 750f4b4 to ffc508f Compare May 6, 2026 02:15
@ledsun ledsun marked this pull request as ready for review May 6, 2026 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant